// pages/Notice_detail/Notice_detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    message_list: '',
    _id: ""
  },
  top_preview(options) {
    const that = this
    var current = options.target.dataset.url
    wx.previewImage({
      urls: that.data.message_list[0].pictures,
      current: current
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      _id: options._id
    })
    let that = this;
    console.log("这是", options._id)
    wx.$cloud.callFunction({
      name: "getIndexInfo",
      data: {
        action: "news",
        _id: this.data._id,
        // _id:"18ed0968619b4675069edff54b00fce0",
        sign: 19,
      }
    }, ).then(res => {
      console.log("----", res.result.data)
      let temp = res.result.data
      let last = new Date(temp.date)
      let string_last = new Date(last).getFullYear() + '年' + (new Date(last).getMonth() + 1) + '月' + new Date(last).getDate() + '日';
      temp.time = string_last;
      var length = temp.texts.length
      var contents = []
      for (let i = 0; i < length; i++) {
        let text = temp.texts[i]
        let picture = temp.pictures[i]
        if (picture == undefined) {
          picture = ""
        }
        contents.push([text, picture])
      }
      console.log("==========", contents)
      that.setData({
        message_list: [temp],
        contents: contents
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})